<?php

/*  lamp-shade_0.1
 *  License: GNU GPL v3
 *  File: ./modules/page/page.php
 *  Authors:    Werner Roets
 *              Frank Adrian
 *  Description:
 *  This class contains all objects that make up a page
 *  and provides functionality for interacting with a page.
 */

require_once("./modules/page/default_header.php");
require_once("./modules/page/default_footer.php");
require_once("./modules/page/content.php");
require_once("./modules/standard/settings.php");
require_once("./modules/standard/exceptions.php");
require_once("./modules/layout/content_layout.php");

abstract class Page
{
    public $Name;
    public $Header;
    public $Footer;
    public $Content = null;
    
    public $Style = null ;//css style object
    private $Javascript = null;//Javascript
    public $Onload;
    
    //Constructor
    public function __construct($page_name)
    {
	$this->Name = $page_name;
	$this->Header = new Default_header($page_name);
	$this->Footer = new Default_footer();
	$this->Content = new Content;
	
    }
    
    public function SetContent(Content $content, Content_Layout $layout)
    {
	$this->Content = $content;
	$this->Content->Layout = $layout;
    }
    
    public function SetLayout(Content_Layout $layout)
    {
	$this->Content->Layout = $layout;
    }
    
    public function SetJavascriptFile($js_file)
    {
	$this->Javascript = $js_file;
    }
    
    //Renders the page and all of its components
    public function Render()
    {	
	print <<<EOF
<!DOCTYPE html>
<html>
    <head>
	<title>{$this->Name}</title>
EOF;
	//header starts
	if(isset($this->Style))
	{
	    print $this->Style->GetHtml();
	}
	if(isset($this->Javascript))
	{
	    print $this->Javascript->GetHtml();
	}
	//header ends
	print <<<EOF

    </head>
    <body>
EOF;
	//Body starts here
	print '
	<!-- Page -->
	<div id="page">';
	$this->Header->Render();
	$this->Content->Render();
	$this->Footer->Render();
	print '
	</div>
	<!-- end Page -->
	';

	//Body ends here
	print <<<EOF

    </body>
</html>
EOF;
    }
    
    abstract function Load($get, $post);
}
?>